﻿using System;
using System.Data;
using DBUtility;
using XCLib.Log;

public partial class Topo_ImpMonitorIndex_TBSXN : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AjaxPro.Utility.RegisterTypeForAjax(typeof(Topo_ImpMonitorIndex_TBSXN));
        if (!IsPostBack)
        {
            txtTime.Text = DateTime.Now.ToString("yyyy-MM-dd");
        }
    }
    /// <summary>
    /// 获取所有选中基站ID字符串
    /// </summary>
    /// <returns></returns>
   /* [AjaxPro.AjaxMethod]
    public string GetTBSID()
    {
        return new BLL.Topo.InformationUtilization().GetTBSID(GetCookies.UserIsn);
    }*/
    /// <summary>
    /// 调用存储过程获取基站性能数据
    /// </summary>
    /// <param name="NEID">基站ID</param>
    /// <param name="STIME">开始时间</param>
    /// <param name="ETIME">结束时间</param>
    /// <param name="STRWHERE">查询条件</param>
    /// <returns></returns>
    private DataSet GetTBSPerformance(string NEID, string STIME, string ETIME, string STRWHERE)
    {
        string[,] str = new string[4, 2] { { "p_ne_id", "string" }, { "p_stime", "datetime" }, { "p_etime", "datetime" }, { "p_strwhere", "string" } };
        string[] v = new string[] { NEID, STIME, ETIME, STRWHERE };
        //string[] v = new string[] { NEID, "2011-08-01 00:00:00", "2011-08-02 00:00:00", STRWHERE };
        DataSet ds= new BLL.Common.mysqldata().GetList("TBS_ZHIBIAO", str, v);
        return ds;
    }
    /// <summary>
    ///获取基站性能数据并进行处理
    /// </summary>
    /// <param name="TBSID">基站ID</param>
    /// <returns></returns>
    [AjaxPro.AjaxMethod]
    public DataSet GetPerformance(string TBSID)
    {
        try
        {
            //string tbsidStr = TBSID.Replace("','", ",");
            //tbsidStr = tbsidStr.Substring(1, tbsidStr.Length - 2);
            string tbsidStr = TBSID;
            
            string[] tbsID = tbsidStr.Split(',');
            DataSet ds = GetTBSPerformance("", DateTime.Now.Date.ToString(), DateTime.Now.ToString(), "'" + TBSID.Replace(",", "','") + "'");
            //DataSet ds = GetTBSPerformance("","2011-05-01 00:00:00", "2011-05-01 23:59:59", "'" + TBSID.Replace(",", "','") + "'");
            DataSetHelper dsh = new DataSetHelper();
            int length = tbsID.Length;
            for (int i = 0; i < length; i++)
            {
                DataTable dt = dsh.RowToTable(ds.Tables[0].Select("NE_ID='" + tbsID[i] + "'"), "Table" + i.ToString());
                if (dt != null)
                {
                    ds.Tables.Add(dt);
                }
            }
            return ds;
        }
        catch (Exception ex)
        {
            CLogSingleton.PolicyOneLog("错误:" + ex.Message, "", DateTime.Now.ToString() + "\r\n获取基站性能数据并添加到数据集,基站ID为:" + TBSID);
            //throw;
        }
        return null;
    }
}
